/**
 * @module: 接口封装
 * @author: xiongsha
 * @date: 2020-05-27 14:13:42
 */

import axios from 'axios';
import { Toast } from 'antd-mobile';

const resuest = (method, url, data?) => {
  const obj: any = {
    method,
    url,
  };
  if (method.toUpperCase() === 'GET') {
    obj.params = data;
  } else {
    obj.data = data;
  }
  return axios(obj)
    .then((res) => {
      return res.data;
    })
    .catch((err) => {
      Toast.info('请关注【生态设计小镇】公众号', 1);
      return Promise.reject(err)
    });
};

export default resuest;
